package demo3;

public class Test {
    public static void eating(Animal a){        //只要是继承了Animal的类均可调用
        a.eat();
    }

    public static void running(IRunning iRunning){      //只要实现了该接口即可调用该方法
        iRunning.Running();
    }
    public static void flying(IFIying ifIying){
        ifIying.Flying();
    }
    public static void swimming(ISwimming iSwimming){
        iSwimming.Swimming();
    }

    public static void main(String[] args) {
        Dog dog = new Dog(5, "小白");
        Bird bird = new Bird(1, "咕咕");
        Animal dog1 = new Bird(6, "小绿");    //此处若这样调用则不可使用接口中的方法
                                                        //因为接口中的方法都是子类实现的
        Robot robot = new Robot();
        //1
        dog.eat();
        //2
        eating(dog);
        //1
        dog.Running();
        //2
        running(dog);
        flying(bird);
        running(robot);     //不是Animal也可调用该接口，只要实现了即可
    }
}
